package com.atguigu.search;

import java.util.Arrays;

/**
 * @author durant
 * @create 2021-11-16 10:06
 */
public class SequenSearch {
    public static void main(String[] args) {
        int[] arr = {1, 8, 10, 89,89, 1000, 1234,89};
        int[] i = sequenSearchAll(arr, 89);
        System.out.println(Arrays.toString(i));
    }

    public static int sequenSearchOne(int[] arr, int value) {

        for (int i = 0; i < arr.length; i++) {
            if (value == arr[i]) {
                    return i;
            }
        }

        return -1;
    }
    public static int[] sequenSearchAll(int[] arr, int value) {
        int[] indexArr =new int[arr.length];
        int index =0;
        for (int i = 0; i < arr.length; i++) {
            if (value == arr[i]) {
                indexArr[index] = i;
                index ++;
            }
        }

        return indexArr;
    }
}
